package File;

import java.io.*;

public class DoFile {
    public static void main(String[] args){
        //复制文件
        File file=new File("E:\\file\\file.txt");
        File file1=new File("E:\\file\\file3.txt");
        try {
            FileReader fileReader=new FileReader(file);
            FileWriter fileWriter=new FileWriter(file1);
            int date;
            while((date= fileReader.read())!=-1){
                fileWriter.write((char)date);
            }
            fileWriter.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        //打印文件内容
        File file2=new File("E:\\file\\file.txt");
        try {
            FileInputStream fis=new FileInputStream(file2);
            int date;
            while ((date= fis.read())!=-1){
                System.out.println((char)date);
            }

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
